package com.hhkj.payment.wechat.notification.service.biz.impl;

import com.hhkj.payment.wechat.notification.common.cont.ResEnum;
import com.hhkj.payment.wechat.notification.common.handler.NotificationHandler;
import com.hhkj.payment.wechat.notification.model.res.NotificationRes;
import com.hhkj.payment.wechat.notification.service.biz.NotificationBizService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

/**
 * WechatPayNotificationBizServiceImpl
 *
 * @author HHKJ-SERVER-ZJ
 * @since 2023/11/22 19:25
 */
@Slf4j
@Service
public class NotificationBizServiceImpl implements NotificationBizService {

    @Autowired
    private NotificationHandler notificationHandler;

    @Override
    public NotificationRes receive(HttpServletRequest request) {
        try {
            notificationHandler.hand(request);
        } catch (Exception e) {
            log.error("微信通知接受数据处理失败,{" + e.getMessage() + "}");
            return ResEnum.FAIL.getRes();
        }
        return ResEnum.SUCCESS.getRes();
    }
}
